#include "../Header Files/CAnimation.h"

CAnimation::CAnimation(CBaseObject* pOwner)
{
	m_nCurrFrame = 0;
	m_bIsPlaying = false;
	m_pOwner = pOwner;
}

CAnimation::~CAnimation()
{
	for( unsigned int i = 0; i < m_vFrames.size(); ++i )
	{
		delete m_vFrames[i];
	}
}

void CAnimation::Update( float _Dt )
{
	static float fTimer = 0;

	if( m_bIsPlaying )
	{
		fTimer += _Dt;

		if (m_vFrames[m_nCurrFrame]->dFrameLength <= fTimer)
		{
			fTimer = 0;
			++m_nCurrFrame;
		}

		if( (int)m_vFrames.size() <= m_nCurrFrame )
		{
			if( !m_bIsLooping )
				m_bIsPlaying = false;

			m_nCurrFrame = 0;
		}
	}
}

void CAnimation::Render()
{
	if( m_bIsPlaying )
	{
		
	}
}

void CAnimation::Reset()
{
	m_nCurrFrame = 0;
}